/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Acceso;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author daniel
 */
public class Acceso {
    
    private Conexion conex;
    private ResultSet consultaSelect;

    public Acceso() {
        this.conex = new Conexion();
    }

    public ResultSet getConsultaSelect() {
        return consultaSelect;
    }

    public void setConsultaSelect(ResultSet consultaSelect) {
        this.consultaSelect = consultaSelect;
    }
    
    public int obtenerId(String consulta){
        try {
              consultaSelect = this.conex.realizarConsulta(consulta);

                  while (consultaSelect.next()) {
                      return Integer.parseInt(consultaSelect.getString(1));
                  }

          return 0;

        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
            return 0;
        }
      finally{
            try {

                this.conex.getStmt().close();

            } catch (SQLException ex) {
                System.out.println("No se pudo cerrar el statament: "+ex.getMessage());
            }
        }
    }
}
